/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

var loadServlet = basePath + 'servlet/common/SimpleInfoLoad';
var _pageSize=20;
var pointTypeStore = new Ext.data.JsonStore({
    url: loadServlet,
    baseParams: {id: 'id', name: 'name', tableName: 't_pointType'},
    autoLoad: true,
    root: 'data',
    fields: ['id', 'name']
});

var pointTypeCombo = {
    xtype: 'combo',
    width: 100,
    store: pointTypeStore,
    id: 'PointTypeCombo',
    displayField: 'name',
    valueField: 'id',
    hiddenName: 'pointTypeId',
    mode: 'remote',
    forceSelection: true,
    triggerAction: 'all',
    fieldLabel: '监测点类型',
    emptyText: '监测点类型...',
    selectOnFocus: true,
    listeners: {
        select: function(combo, record, index) {
            store.baseParams.pointTypeId = combo.getValue();
        }
    }
};

var pointType2Store = new Ext.data.JsonStore({
    url: loadServlet,
    baseParams: {id: 'id', name: 'name', tableName: 't_pointType2'},
    autoLoad: true,
    root: 'data',
    fields: ['id', 'name']
});

var pointType2Combo = {
    xtype: 'combo',
    width: 100,
    store: pointType2Store,
    id: 'PointType2Combo',
    displayField: 'name',
    valueField: 'id',
    hiddenName: 'pointType2Id',
    mode: 'remote',
    forceSelection: true,
    triggerAction: 'all',
    fieldLabel: '城农网类别',
    emptyText: '城农网类别...',
    selectOnFocus: true,
    listeners: {
        select: function(combo, record, index) {
            store.baseParams.pointType2Id = combo.getValue();
        }
    }
};

var voltageLevelStore = new Ext.data.JsonStore({
    url: loadServlet,
    baseParams: {id: 'id', name: 'name', tableName: 't_voltageLevel'},
    autoLoad: true,
    root: 'data',
    fields: ['id', 'name']
});

var voltageLevelCombo = {
    xtype: 'combo',
    width: 100,
    store: voltageLevelStore,
    id: 'VoltageLevelCombo2',
    displayField: 'name',
    valueField: 'id',
    hiddenName: 'voltageLevelId',
    mode: 'remote',
    forceSelection: true,
    triggerAction: 'all',
    fieldLabel: '电压等级',
    emptyText: '电压等级...',
    selectOnFocus: true,
    listeners: {
        select: function(combo, record, index) {
            store.baseParams.voltageLevelId = combo.getValue();
        }
    }
};

var reportStatusStore = new Ext.data.SimpleStore({
    fields: ['id', 'reportName'],
    data: [[0, '观测'], [1, '上报'], [-1, '全部']]
});

var reportCombo = {
    name: 'reportStatus',
    id: 'ReportStatus',
    xtype: 'combo',
    fieldLabel: '上报状态',
    width: 100,
    triggerAction: 'all',
    emptyText: '上报状态...',    
    hiddenName: 'reportStatus',
    editable: false,
    store: reportStatusStore,
    displayField: 'reportName',
    valueField: 'id',
    mode: 'local',
    listeners: {
        select: function(combo, record, index) {
            store.baseParams.reportStatus = combo.getValue();
        }
    }
};

//启用/停用状态
var startStatusStore = new Ext.data.SimpleStore({
    fields: ['id', 'startStatus'],
    data: [[9,'未启用'],[0, '停用'], [1, '启用'], [-1, '全部']]
});

var startCombo = {
    name: 'startStatus',
    id: 'StartStatus',
    xtype: 'combo',
    fieldLabel: '启用/停用',
    width: 100,
    triggerAction: 'all',
    emptyText: '启用/停用状态...',    
    hiddenName: 'startStatus',
    editable: false,
    store: startStatusStore,
    displayField: 'startStatus',
    valueField: 'id',
    mode: 'local',
    listeners: {
        select: function(combo, record, index) {
            store.baseParams.startStatus = combo.getValue();
        }
    }
};

var rangeStore = new Ext.data.SimpleStore({
    fields: ['id', 'range'],
    data: [[0, '母口径'], [1, '子口径'], [-1, '全口径']]
});

var rangeCombo = {
    name: 'range',
    id: 'Range',
    xtype: 'combo',
    fieldLabel: '口径',
    width: 100,
    triggerAction: 'all',
    emptyText: '统计口径...',    
    hiddenName: 'range',
    editable: false,
    store: rangeStore,
    displayField: 'range',
    valueField: 'id',
    mode: 'local',
    listeners: {
        select: function(combo, record, index) {
            store.baseParams.range = combo.getValue();
        }
    }
};

var haveStore = new Ext.data.SimpleStore({
    fields: ['id', 'have'],
    data: [[1, '无数据'], [2, '有数据'], [-1, '全部']]
});

var haveCombo = {
    name: 'have',
    id: 'Have',
    xtype: 'combo',    
    width: 100,
    triggerAction: 'all',
    emptyText: '有无数据...',    
    hiddenName: 'have',
    editable: false,
    store: haveStore,
    displayField: 'have',
    valueField: 'id',
    mode: 'local',
    listeners: {
        select: function(combo, record, index) {
            store.baseParams.have = combo.getValue();
        }
    }
};

var pointText= {
            xtype: 'textfield',
            name: 'pointName',
            emptyText: '输入监测点名称'
            ,id:'PointName',
            listeners:{
                change:function( c, newValue, oldValue ){
                    store.baseParams.name = newValue;
                    //store.baseParams.pointName = newValue;
                }
            }
        };

var searchButton = {
            xtype: 'button',
            text: '搜索',
            iconCls: 'icon-search',
            width: 60,
            style: {marginLeft: '20px'},
            handler: function() {                
                store.load({params: {start: 0, limit: _pageSize}});
            }
        };
        
var tbarPoint = new Ext.Toolbar({
    items: [
        pointTypeCombo, pointType2Combo, voltageLevelCombo,reportCombo
                ,pointText,searchButton
        
    ]
});
